extract path building into its own method