fix sum, more debug output