implemented compare_to method