refactor and add comments to doc