Modified code for both simMig and migrate