I've used the second example with the case statement, and that appears to be working as expected

Can you comment the code so that I can understand why it works

Thanks

Malc