Fixed minor bug in connectEx function