Might be nice to put this in its own file, but maybe that's for another PR?