Refactored tasks controller