abstracting search function