Handle undefined scenarios better