refactoring. proper view swapping