refactoring and some notes