closest point code added