Fix for possible infinitie loop in searches