public void updateGroup(Group f) {
        if (groups == null) {
            updateGroups();
        }
        //save changes to db
        MongoHelper.save(f, MongoHelper.GROUP_COLLECTION);

        if (!user.getGroups().contains(f.getId())) {
            //user doesn't have the group yet
            user.addGroup(f.getId());

            //brand new group, just store it in our map and save it
            groups.put(f.getName(), f);
            groupIdNameMap.put(f.getId(), f.getName());
            //add to our name list
            groupNames = groups.keySet().toArray(new String[0]);

            if (groupNames.length > 1) {
                Arrays.sort(groupNames);
            }
            
            //save user to DB
            MongoHelper.save(user, MongoHelper.USER_COLLECTION);
        } //update local group
        else if (f.getName().equals(groupIdNameMap.get(f.getId()))) {
            //no name change
            groups.put(f.getName(), f);
        } else {
            //update with new name
            //remove old maping
            groups.remove(groupIdNameMap.get(f.getId()));
            //put in new maping
            groups.put(f.getName(), f);
            groupIdNameMap.put(f.getId(), f.getName());
            
            groupNames = groups.keySet().toArray(new String[0]);

            if (groupNames.length > 1) {
                Arrays.sort(groupNames);
            }
        }

    }