fix atomic write