fix search loop