Fix algorithm about precedence.