[BUGFIX] Missing check before foreach loop