scoping problem fixed