improved code for migrator