edited mdl to run using distance