replace exit with sys.exit