Trying to find source of NaNs