Refactor the extractPath method and refactor methods that depends of extractPath().