template error fix
continued bugfixing
final template fix