added group attribute to model matrix func