slight modification to display algorithm