Fix a bug: always used a default template instead of a loaded template