Possible fix for NaN problem