added leftMost and sortedSheep function