I must to admit the code complexity into this loop intimidates me :P How would you feel avoid using functions to reduce complexity and help with code readability?