if need to sort mappings, also index
second stab at last stages