some more error handling in writer