Fix issue with wrong local variable