more refactoring and changes