Fixed issue #69 and refactored the job selection loop