Cleaned up the presentation of the buy function