Corrected override of the equals method