Refactoring object template code