implement nodeDistance