fixed some bug in do_purchase