Refactored cart controller to dry up discount function