changed n to length(e)
added resamps