Moved some JS to the right place