correctly bind this in write()