handle the return code properly