Checking in because I don't want to lose this rather neat code for