implemented distance integral