Move mp finding code into a method so we can easily call it multiple times