refactor for better encapsulation