initial changes and refactoring