Fantastic code I came across. Seems so obvious in hindsight and I wish I had come up with it! Oh well, there's plenty more problems to do!