Added nearest point functionality