Fix a bug and template file