First try, better query handling