Refactor into a util.