Refactor add task to reduce coupling