refactoring for encapsulation