proper variable scoping