better path function, still testing