Added validation for undefined container