initial refactoring to fit into new app template approach