cursor.close() issues fixed