fixed js for finished loading