more changes and refactoring