clean migration spagetti code