finished encapsulation refactoring