FIxing issue with sorting