bulk of code works. Now ouputs total based on table