refactor for upsample