refactoring of createData promise