add doc comments
minor refactor and rename