search function with sql on the way