refactoring and code cleaning