Refactoring to use go templates