minor changes and refactoring