Fix in compareTo so that it checks perimiter as well.