Updated Visitor pattern with generics