refactored visitor and util