better way to count the rules