conected and disconnected method

mofified the method for a more appropriate usage