Actually the code does calculate the correct sum...