Corrected initialization of sum to 0.0.