fully functioning html output, added docstring comments to help with readability