cleaned up some of the code and added more documentation and explanation for choices made