refactoring worker related codes into modules/classes