Fixed template substitution to follow spec properly