refactoring workorders controller