Refactor path building