Version 2

    The following apparently straightforward code caused me a lot of confusion.

     

    The fix is a simple change but one that would have escaped me for a long time: