refactor views to DRY up code