Use scoped variables instead of global