changed init & disconnection code