bug fixing for variable scope...