refactored code to try to get it to display correctly