Add time for jobs and divide next function into 2 separated queries