Add check to avoid crash