implementing path finding