Extracted trackDIst functions
Changed median calculation