fix search function