Reimplement remap function.