Creates search function