How to check for reverse polarity