fixing race condition in CreatePages