main/template refact