reordered js a little