Refactored viewcontroller into another class, and made the application only do db calls once