create search function