fix for variable scope