diff --git a/admin/ajax/togglegroups.php b/admin/ajax/togglegroups.php
index 1a0dc22be8eef64a0fd5a0a64121b1ca7dc3b06e..3210252af02878839dd0725ccb4660945d1c5f3d 100644
--- a/admin/ajax/togglegroups.php
+++ b/admin/ajax/togglegroups.php
@@ -28,6 +28,10 @@ if( OC_Group::inGroup( $username, $group )){
 	$action = "remove";
 	$error = "remove user from";
 	$success = OC_Group::removeFromGroup( $username, $group );
+	$usersInGroup=OC_Group::usersInGroup($group);
+	if(count($usersInGroup)==0){
+		OC_Group::deleteGroup($group);
+	}
 }
 else{
 	$success = OC_Group::addToGroup( $username, $group );