Removed duplicate code for template getting