remove unnecessary loop while doing search