fixed some scoping stuff