Yeah that function is a copy-and-paste of some *old* code I wrote in my Python-beginner days! I'd better tidy it up if it is going on show...