try to figure out insane javascript timing problems