working version of get dist