Refactor : reduce code complexity

2 jobs for master in 3 minutes and 25 seconds (queued for 1 second)