js timing bug fix