updated js so no more NaNs