refactored view.js