more robust path handling