refactored tasks controller