write tsd distance as score