Fixing a couple errors in query