some tidying
messing with scope