Refactor views to remove code duplication