Fixed a bug with scoping