changes in script and refactored coupon validation code