In onFirst() function definition, there's a line: for (type in types) `type` is made global since there is no `var`.