CLN: rewrite templates
CLN: refactor to templates