added a missing error check