Try to handle potential NaN values