Added check for undefined team