update compareTo function

NEED TESTING TO CHECK HOW IT GOES