begin refactor for templating