Modified where write() is called