Refactor MainCtrl to use messages array