fixed bugs in templates