updated to make the create function more resilient