Implemented visitor and iterator pattern