fixed scoping problem