upgrades and refactoring