Refactor display logic into a class