Refactoring savecontent

Use ``switch`` statement instead multiple ``if endif``. Faster and better to maintain and understand.