Fix build_template bug