Implemented Visitor pattern problem