use proper variable scoping