Implemented main loop class