Adding error treatment