upsample and down sample code