patches: fixed bug in patches closest