error handling - deal with case of undefined variable passed in queries