fix small global namespace pollution

`d` variable ends up in the global namespace. This commit fix this behavior by declaring a local variable.