Fixing up loose javascript