Refactored view logic into classes