added the sorting- phase 3