mainview refactoring