fixed bug in nan_detrend
work in progress