Fixed the division by zero problem in discount calculation