refactoring deregister, get_next_job