fixed bugs in template