added open/close any kind of tag functionality and refactored auto close to implement it