Bugfix: incorrect use of local variable