Split formatting logic into own module