moved everything out of template and refactoring code
Merge pull request #2 from mishulyno87/feature/set_default_layout

moved everything out of template and refactoring code