added resampling function, found possible problem in getScales