moving worker related code to separate file