refactoring for better encapsulation