Attempted to fix NaN bug