working on cleaning up the code and documenting it all