updated equals function and added hash