added path finding code that connects all the parts