some small refactor and document improvement