simplified code and removed local variable scriptTagLen