fixing path sum algorithm