refactor process_task