Fixed bug with connect()