error handling for "E_WARNING: Invalid argument supplied for foreach()"

Signed-off-by: seferov <farhad.safarov@gmail.com>