Formatted and commented all of the code