refactoring and some minor changes