Implemented atomic write for aritrary target types