added better handling of the null connection in the connection manager