Main search function not working