refactor task's code a bit