tried to fix NaN problem but haven't yet