debugging the end of query exception