minor refactoring and doc update