Added #include <algorithm>