         c.IsDeleted = 0 and	
         c.TopicMovedID is null and
         c.NumPosts = 1
-
-      select @PageIndex = @PageIndex+1;
-      select @firstselectrownum = (@PageIndex - 1) * @PageSize + 1 
-        -- find first selectedrowid 
-   if (@firstselectrownum > 0)   
-   set rowcount @firstselectrownum
-   else
-   -- should not be 0
-   set rowcount 1
-    
-    select		
-        @firstselectposted = c.LastPosted
-    from
-        [{databaseOwner}].[{objectQualifier}Topic] c
-        join [{databaseOwner}].[{objectQualifier}User] b on b.UserID=c.UserID
-        join [{databaseOwner}].[{objectQualifier}Forum] d on d.ForumID=c.ForumID
-        join [{databaseOwner}].[{objectQualifier}ActiveAccess] x on x.ForumID=d.ForumID
-        join [{databaseOwner}].[{objectQualifier}Category] cat on cat.CategoryID=d.CategoryID			
-    where
+	
+	select @PageIndex = @PageIndex+1;
+	select @FirstSelectRowNumber = (@PageIndex - 1) * @PageSize + 1;
+	select @LastSelectRowNumber = (@PageIndex - 1) * @PageSize + @PageSize;
+	
+	with TopicIds  as
+	 (
+	 select ROW_NUMBER() over (order by cat.SortOrder asc, d.SortOrder asc, c.LastPosted desc) as RowNum, c.TopicID
+	 from  [{databaseOwner}].[{objectQualifier}Topic] c
+	 	join [{databaseOwner}].[{objectQualifier}Forum] d on d.ForumID=c.ForumID
+        join [{databaseOwner}].[{objectQualifier}ActiveAccess] x  with(nolock) on x.ForumID=d.ForumID
+        join [{databaseOwner}].[{objectQualifier}Category] cat on cat.CategoryID=d.CategoryID
+	where
         c.LastPosted IS NOT NULL and (c.LastPosted between @SinceDate and @ToDate) and
         x.UserID = @PageUserID and
         CONVERT(int,x.ReadAccess) <> 0 and
         cat.BoardID = @BoardID and
-        (@CategoryID is null or cat.CategoryID = @CategoryID) and
+        (@CategoryID is null or cat.CategoryID=@CategoryID) and
         c.IsDeleted = 0 and	
-        (c.TopicMovedID is null) and
-        (c.NumPosts = 1)
-    order by
-     c.LastPosted desc,
-        cat.SortOrder asc,
-        d.SortOrder asc,
-        d.Name asc,
-        c.Priority desc		
-            
-    set rowcount @PageSize	
-
-select
-        c.ForumID,
+        c.TopicMovedID is null and
+        c.NumPosts = 1
+	  )	  
+	  select
+		c.ForumID,
         c.TopicID,
-        c.TopicMovedID,
+        c.TopicMovedID,		
         c.Posted,
         LinkTopicID = IsNull(c.TopicMovedID,c.TopicID),
         [Subject] = c.Topic,

    where	  EventLogID <= @FirstSelectRowID and (b.UserID IS NULL or b.BoardID = @BoardID) and (@EventIDs IS NULL OR  a.[Type] IN (select * from @ParsedEventIDs)) and a.EventTime between @SinceDate and @ToDate	
      order by a.EventLogID  desc   
   end  
 set nocount off

end

        c.IsDeleted = 0
        and	c.TopicMovedID is null
        and c.TopicID = (SELECT TOP 1 mess.TopicID FROM [{databaseOwner}].[{objectQualifier}Message] mess WHERE mess.UserID=@PageUserID AND mess.TopicID=c.TopicID)	
	
	select @PageIndex = @PageIndex+1;
	select @FirstSelectRowNumber = (@PageIndex - 1) * @PageSize + 1;
	select @LastSelectRowNumber = (@PageIndex - 1) * @PageSize + @PageSize;
	
	with TopicIds  as
	 (
	 select ROW_NUMBER() over (order by cat.SortOrder asc, d.SortOrder asc, c.LastPosted desc) as RowNum, c.TopicID
	 from  [{databaseOwner}].[{objectQualifier}Topic] c
	 	join [{databaseOwner}].[{objectQualifier}Forum] d on d.ForumID=c.ForumID
        join [{databaseOwner}].[{objectQualifier}ActiveAccess] x  with(nolock) on x.ForumID=d.ForumID
        join [{databaseOwner}].[{objectQualifier}Category] cat on cat.CategoryID=d.CategoryID
  where
        (c.LastPosted between @SinceDate and @ToDate) and
        x.UserID = @PageUserID and
        CONVERT(int,x.ReadAccess) <> 0 and
