wd fixes and corr.r

will return incorrect answer if threshold is set higher than maximum