add discount and fix some bugs