refactor toggleFormat
copy classes after toggleformat