finally implemented visitor pattern