functional, but needs significant speedup
with helper paths