new function to search in db