variable scope still buggy