Adding error processing