refactored worker