avoid panic with better path len check