extracted main loop of base server to commandhandler