some refactoring before the merge to master