Add writeTo method