David fixes a bug in insert_rule