updated search function