[refactored] code clean up and documentation