added path-writing function for mapper