Fix timing issue for js