I start from this revision to refactor the code
refactoring completed
work in progress
improved names and comments