fixed very inefficient search bug