query fix and closing tag fix