"d" is a local variable

Without "var" it will be global.