Fixed potential bug in search