added functionality for rearranging mismatched IDs