code refactoring for migration scripts