change cr.execute() by logged_query()