improved entering and exiting search