Improves searching logic