Added Distance processing
bug fix