Refactor, move formatter into a helper fn.