add an extra error check