added pathfinding along with performance improvements by grouping blocks