refactored a bunch of code in main view to separate vc from views