Updated Object.equals() to handle different types