Updated so that comparison (b,a) isn't computed if comparison (a,b) has already been run