Improved object comparison logic