reorginized javascript