Refactoring visitor class