some minor changes and refactoring
some minor changes