added a new polarity algorithm and lookup functions