fixed javascript init bugs