Creating the buy function