Merge same rules into one rule