working error code handling