Refactored worker functions