added exception handling to connection and channel