fixing a bug with error codes (part 1/2)