check for id mismatch and handle race condition