Adding error checks