refactoring and simplification