some code cleaning/refactoring