refactor MainApp into simpler methods