Trying to understand scoping on my JS code...