Remove usage of deprecated function setPattern()

and replace with replacement function setPath()