return path building moved into its own function, empty error returning added
error variable