Fix undeclared variable on create template function