fixing some scoping issues