fixed comparison

redone the comparison function