clean up write