make path() function more flexible