optimize display logic