fixed search function, had a conflict of variable naming