cleaned up some code, and then added some commenting