added exception for null connection.