Refactoring code for theme and template radio button.