added sys.exit(0) to end of main to ensure correct return code