Fixed calculating the total. Also, minimized code a bit.

v1.0.1