path finder, second implementation