again some refactoring and code cleaning