Viewing queries works but there is a bug in the query code