fixed scope of some variables
v1.0.1