Removed console.log
Cleanup. Moved code into functions. Added comments