Rework of writer. Now it use templates