fixed search
 made quit conditions...