better method to control sign flipping