calculate_discount function working