make migration functional and refine