handling transition states while connecting and disconnecting. needs more testing.