reimplemanted resampling for EVD
merged changes