add path writing function