rebuild including remap function