added the buy function