bug fix for maxsum