improve migration script