change implementation of the writes function