tuning and refactoring for the migration