update the buy function