Fix migrate exit condition

I felt into the C progrmmer's trap of accidentally using `=` instead of `==`. This is not good. Good catch @jlee-r7.

This commit fixes this, swaps the values around and tidies up code a bit.