Fixed NaN problem