fixed local/global scope problem