Fixed silly Javascript scoping problem