updates and refactoring