Cleaning up get group function