fixing condition to display data (wrong order)