Cleaned up isSorted