refactor the display code to reduce parameters