There are two consecutive loops "from i in 0..data_runs.size-1" just asking if they can be merged. Maybe the answer is just NO! i see the loop above is modifying real_loc which is used in this second loop. Sorry for my weird knowledge about the MFT and for asking before reading the references you've included before the function header. Taking the easy way... (:$ shame)