fixes a problem traversing elements