first draft of resampling finished. need to test it