Refactoring: encapsulation of visited