Fixed loop that could happen when searching