Fix function to compare two objects