PR #648 - add checks for queries