 	UserID int
 )
 INSERT INTO @Users (UserID)
-SELECT '
-
-IF @OnlyFind = 1
-SET @sqlUsers = @sqlUsers + 'TOP ' + CAST(@MaximumRows AS varchar(12)) + ' '
-
-SET @sqlUsers = @sqlUsers + 'U.UserID
+SELECT 
+	U.UserID
 FROM UsersDetailed AS U
 WHERE 
 	U.UserID <> @UserID AND U.IsPeer = 0 AND

		ItemID int
	)
	INSERT INTO @ItemsService (ItemID)
	SELECT '

IF @OnlyFind = 1
SET @sqlSpace = @sqlSpace + 'TOP ' + CAST(@MaximumRows AS varchar(12)) + ' '

SET @sqlSpace = @sqlSpace +	'SI.ItemID
	FROM ServiceItems AS SI
	INNER JOIN Packages AS P ON P.PackageID = SI.PackageID
	INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID

		EA.AccountID as AccountID
	FROM @ItemsService AS I2
	INNER JOIN ServiceItems AS SI2 ON I2.ItemID = SI2.ItemID
	INNER JOIN ExchangeAccounts AS EA ON I2.ItemID = EA.ItemID'
IF @FilterValue <> ''
	SET @sqlSpace = @sqlSpace + ' WHERE (EA.DisplayName LIKE ''' + @FilterValue + ''')'
SET @sqlSpace = @sqlSpace + '
	UNION
	SELECT '

IF @OnlyFind = 1
SET @sqlSpace = @sqlSpace + 'TOP ' + CAST(@MaximumRows AS varchar(12)) + ' '

SET @sqlSpace = @sqlSpace +	'
		EA4.ItemID AS ItemID,
		EA4.PrimaryEmailAddress as TextSearch,
		''ExchangeAccount'' as ColumnType,
