minor changes and refactor