Thanks, betterworld.
Your proposal works.
When you say a variable should not be defined more than once in a block - I did not think I did that in the code as the second declaration is conditional to the variable not being defined.
Am I missing anything here?