Handle connect() correctly