Fix error caused by undeclared loop variable

Signed-off-by: Niklas Koep <niklas.koep@gmail.com>