implements write record