templating and cleaning