refactoring plus new documentation and test