complete buy function