updated some of the code.  Read comments