Maintenance : Cursor cannot be creted without a working connection + safer code