Refactor code to check job existence in deployment