fix cleanup code to not happen in main module
typo fix, index is in arguments[0]