some refactoring and notes