I'm sure there are better implementations, but this feels clean enough for now. Let's see if this is useful or not.