refactored ui display code to make it easier to support different display modes