Add a check for an array to prevent fatal error