Added totalWeight function

This is only used for a very specific project.