Remove first definition of readAttributes which is replaced by the second one where attributes is an array.
Also, declare local variables with var.
Added var to properly declare local variables so that they don't pollute the global namespace and risk multi-threading conflicts.