updated code to deal  with kt==NaN. Needs some work still.