refactor the task validation