Refactor and format.