cleaned up maxfrequency, added way to pick sum