Updating query documentation and fixing output