Fixed the maxBy to be 0 when the set is empty. Using foldLeft