wrote compareTo method