Fix incorrect cast in equals method