Fixed a bug where discount value causes an exception