Improve path validation