refactored for clarity and added test for missing job