combine these calls. you ALWAYS want a cookie when inserting, so make it a single call and put the mutex inside.