Small bugfix with wrong variable scope