Refactor display logic