Fixed problems with scope