Updated compare function

Added condition for "no common elements"