factorise code of transition migration