fixing logic issues with discount calculations