Since templates[template] are used twice, we should assign it to a variable so it's only called once.