added buy function