Added error checking to handle race condition on insertOrUpdate method.