setTimeout addition to fix some weird cases with ie8