added lastConnected handling