Refactor job handling