some refactoring and renaming