Addressed Augusto's comments, freddie proofed back end.

cleaned up some code, encapsulated the addSetsToTable into a function to
call from wherever.