added a bit more checking for nil values, a few were squeaking into the hostgroups list