refactor and doc