move runMainLoop method to superclass