Refactor to services and clean tasks controller