refactored view code