added logging and proper handling of jobs during each