improved main.tpl