Added pip value check for zero to avoid division by zero.