- added comments and cleaned up some of the code