fix: Invalid argument supplied for foreach()