public void updateActivity(Activity a) {
        if (activities == null) {
            updateActivities();
        }
        //System.out.println(a);
        //save changes to db
        MongoHelper.save(a, MongoHelper.ACTIVITY_COLLECTION);

        if (!user.getActivities().contains(a.getId())) {
            //user doesn't have the activity yet
            user.addActivity(a.getId());

            //brand new activity, just store it in our map and save it
            activities.put(a.getName(), a);
            activityIdNameMap.put(a.getId(), a.getName());
            //add to our name list
            activityNames = activities.keySet().toArray(new String[0]);

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

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