first version of maxSumPath