Moved 'controller' code for dashboard to separate file