Fix path replacement subroutine