prevents "Invalid argument supplied for foreach()"