basic templating and save function