remove redundant tests and terminate using process return codes