Refactors code out into views