Updated search function