Search function fixes