refactor view code into a couple helpers