clean up and error simulation