cleaned up code and added some documentation
cleaned up code and added some documentation