moving the logic out of the comparaison function