search loop working