handle exit status correctly