refactoring task code.