New generic buy function