updated documentation
condensed some of the code