fix buy logic