used std::equal for comparison