diff --git a/indra/newview/alchatcommand.cpp b/indra/newview/alchatcommand.cpp
index 41dfa26d5d99fbc3c4f9fe5412aaf577bee94352..cfcf726fb4e085fb9670d2fc298922b6ea539bf5 100644
--- a/indra/newview/alchatcommand.cpp
+++ b/indra/newview/alchatcommand.cpp
@@ -135,17 +135,7 @@ bool ALChatCommand::parseCommand(std::string data)
 			msg->nextBlockFast(_PREHASH_AgentData);
 			msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
 			msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-			LLUUID group_id = gAgent.getGroupID();
-			if (gSavedSettings.getBOOL("AlchemyRezUnderLandGroup"))
-			{
-				LLParcel* land_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
-				// Is the agent in the land group
-				if (gAgent.isInGroup(land_parcel->getGroupID()))
-					group_id = land_parcel->getGroupID();
-				// Is the agent in the land group (the group owns the land)
-				else if (gAgent.isInGroup(land_parcel->getOwnerID()))
-					group_id = land_parcel->getOwnerID();
-			}
+			LLUUID group_id = gAgent.getGroupForRezzing();
 			msg->addUUIDFast(_PREHASH_GroupID, group_id);
 			msg->nextBlockFast(_PREHASH_ObjectData);
 			msg->addU8Fast(_PREHASH_PCode, LL_PCODE_VOLUME);
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 26edbec4ea364aa9d21c77d1cb00148336327b81..f7e50950cec04f07502ccddca9fa007a48ec44a0 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -5195,4 +5195,19 @@ void LLTeleportRequestViaLocationLookAt::restartTeleport()
 //    gAgent.doTeleportViaLocationLookAt(getPosGlobal());
 }
 
+LLUUID LLAgent::getGroupForRezzing()
+{
+	if (gSavedSettings.getBOOL("AlchemyRezUnderLandGroup"))
+	{
+		LLParcel* land_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
+		// Is the agent in the land group
+		if (gAgent.isInGroup(land_parcel->getGroupID()))
+			return land_parcel->getGroupID();
+		// Is the agent in the land group (the group owns the land)
+		else if (gAgent.isInGroup(land_parcel->getOwnerID()))
+			return land_parcel->getOwnerID();
+	}
+	return LLUUID::null;
+}
+
 // EOF
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index fb5ef12c65907db4ea46904a380e7924f40e4a39..77ff3507fbf826e9f396c432dcd55b06e0a347ad 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -905,6 +905,7 @@ class LLAgent : public LLOldEvents::LLObservable
 public:
 	void			setHideGroupTitle(BOOL hide)	{ mHideGroupTitle = hide; }
 	BOOL			isGroupTitleHidden() const 		{ return mHideGroupTitle; }
+	LLUUID			getGroupForRezzing();
 private:
 	std::string		mGroupTitle; 					// Honorific, like "Sir"
 	BOOL			mHideGroupTitle;
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 1a327a3778acc0e802abf027dffe1f8704717a19..86c31e22a8877e1546d6b11a009af7f076165024 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -4077,7 +4077,7 @@ void LLSelectMgr::packDuplicateOnRayHead(void *user_data)
 	msg->nextBlockFast(_PREHASH_AgentData);
 	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
 	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
-	msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID() );
+	msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupForRezzing() );
 	msg->addVector3Fast(_PREHASH_RayStart, data->mRayStartRegion );
 	msg->addVector3Fast(_PREHASH_RayEnd, data->mRayEndRegion );
 	msg->addBOOLFast(_PREHASH_BypassRaycast, data->mBypassRaycast );
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index f65ae6d63785866230bcbf6cf774183a8423d844..00703d4fe2d345c8b3f83f2c5d72ed65dacb04fe 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -1330,7 +1330,7 @@ void LLToolDragAndDrop::dropObject(LLViewerObject* raycast_target,
 	msg->nextBlockFast(_PREHASH_AgentData);
 	msg->addUUIDFast(_PREHASH_AgentID,  gAgent.getID());
 	msg->addUUIDFast(_PREHASH_SessionID,  gAgent.getSessionID());
-	msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID());
+	msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupForRezzing());
 
 	msg->nextBlock("RezData");
 	// if it's being rezzed from task inventory, we need to enable
diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp
index 34d33743b9403b080d656a27f122c4577133ab91..b87659ad3691c37042536bdd4b323828d4a733bc 100644
--- a/indra/newview/lltoolplacer.cpp
+++ b/indra/newview/lltoolplacer.cpp
@@ -245,7 +245,7 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics )
 	gMessageSystem->nextBlockFast(_PREHASH_AgentData);
 	gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
 	gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-	gMessageSystem->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID());
+	gMessageSystem->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupForRezzing());
 	gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
 	gMessageSystem->addU8Fast(_PREHASH_Material,	material);