Modified isConnected() method (now it waits for result)