Fixed 'Invalid argument supplied for foreach()' warning