Fixed error handling so ids are updated properly