fixed a big timing flaw in prepare data