@ajdawson, I like this, really clever way of generalising it