Reduce number of getTemplate() calls

Slayer95 pointed out that this is a better implementation.