Added isRegionEmpty function