Addind a check to avoid dividing by zero.