Hopefully fix variable scoping issue.

I don't really understand Ruby. Can you tell?