Replaced some code in CompareTo