Fixed bug in compareTo