fixed remap function