changed parameters in write function