reorder GenerateRules() to get rid of unnecessary if()