correcting a scoping varaible issue