refactored view switching