Fixed application freeze caused by duplicate index.

This was wrong because JavaScript does not have any scopes whatsoever by
specification.