bug fix -- Invalid argument supplied for foreach()