Added safeguard for infinity.