try catch for connecting