refactored the content display logic to make it faster and leaner