better handling of the exit code