Curiosity: In the previous PR this used to be a simple series of if/elseif.../else. Why did it change to a loop with stages? I think the previous code was clearer.