corrected logic on variable visiblity.