added proper timetag in write function