fixing error-prone use of for (var ... in ...)