refactored template