rearranged JS scripts