correct output without sorting