Implemented the hashCode method to be consistent with the equals method