Search loop functioning