Made group function simple and logical