Added compare algorithm