fixed search function repeating bug