Fixed a bug in polarity coloring