Merged
Thanks @jmx for clearly identifying the problem and proposing the fix - it was good; I just wanted to do a bit more.