Added new changes to the connect() function.