Using variables outside of the scope of a BindLink, ForAllLink, ThereExistsLink or AverageLink is a bad idea -- they are "free variables" and they won't do what you expect them to.