moved buy logic to scan script