Implemented distance constraint