fixed incorrectly applied discount calculation