replaced sys.exit with SystemExit