OK, spotted the problem, I think - see changes to the solution in the 2nd post above.

Mike