fixing scoping problem