Fix: Do not search up to maximum index of tags and attributes