Removing unused sum variable