some edits. 

Great stuff. Made some edits that tidy up the code and watertight the code a little