some refactoring and comment addition