This function is a little opaque. Consider adding a docstring explaining what it is for.