refactoring PathController edit function