fix typo+dom not ready+unclose div tag

after doing stress test.. found that my previous patch not working..my bad, since im just restructuring without test.