This was just a copy the the existing SelfPath code