minor refactoring and changes