made the sorted() calls more understandable