add error handling to connect section