Fix recent distance code