Changed error checks