MainController and app logic