Added missing include <algorithm>