function to compare objects