changed exit(1) to rethrows