fix search function bug