refactoring and other changes