Adding error dealing functions.