task.js refactored