improve path handling