Changed to write function