added comment on assigning total to the calculation of the function