refactor views, move functions into view helper