refactoring basic template