invalid loop sys.error; cleaning up