added demean option to Detrend function