refactor visitor with .type