Refactoring of some task functionality to TaskService