trying to fix NaN problem