Would be good to document what this function does.