fixed some bugs with searching