fix a bug which cause process exit

access item with index i cause a "ReferenceError: i is not defined"
error wich finally make process exit