simplified conditional statement in comparison function