Better implementation of GroupRect using templtes