add TODO use ElementFilter to avoid casting and instanceOf