Updated code to work with group