modified getElementsByTagType to be typesafe