fixed bugs in display logic