Revised the example, added an exception if controller is not connected