was missing several error checks