some refactoring
some refactoring and code cleaning