fix random rule creation and rule checking