modify buy logic