fix bug, add distance