fixex some scoping problem