             StarterStyle = case(@StyledNicks)
             when 1 then  b.UserStyle
             else ''	 end,
-                    LastUserStyle= case(@StyledNicks)
+            LastUserStyle= case(@StyledNicks)
             when 1 then  (select top 1 usr.[UserStyle] from [{databaseOwner}].[{objectQualifier}User] usr with(nolock) where usr.UserID = c.LastUserID)
             else ''	 end,
             LastForumAccess = case(@FindLastRead)
              when 1 then
-               (SELECT top 1 LastAccessDate FROM [{databaseOwner}].[{objectQualifier}ForumReadTracking] x WHERE x.ForumID=c.ForumID AND x.UserID = c.UserID)
+               (SELECT top 1 LastAccessDate FROM [{databaseOwner}].[{objectQualifier}ForumReadTracking] x WHERE x.ForumID=c.ForumID AND x.UserID = @UserID)
              else ''	 end,
             LastTopicAccess = case(@FindLastRead)
              when 1 then
-               (SELECT top 1 LastAccessDate FROM [{databaseOwner}].[{objectQualifier}TopicReadTracking] y WHERE y.TopicID=c.TopicID AND y.UserID = c.UserID)
-             else ''	 end,	
-            TotalRows = @post_totalrowsnumber,
-            PageIndex = @PageIndex
-    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	
-        WHERE c.ForumID = @ForumID		
-        AND  c.Priority=2 
-        AND	c.IsDeleted=0
-        AND	(c.TopicMovedID IS NOT NULL OR c.NumPosts > 0) 
-        AND
-        ((@ShowMoved = 1)
-        or
-        (@ShowMoved <> 1 AND  c.TopicMovedID IS NULL))		
-    order by
-         c.Priority DESC,	c.LastPosted DESC		
-
-        SET ROWCOUNT 0		
+               (SELECT top 1 LastAccessDate FROM [{databaseOwner}].[{objectQualifier}TopicReadTracking] y WHERE y.TopicID=c.TopicID AND y.UserID = @UserID)
+             else ''	 end,         
+             c.TopicImage,           
+             0 as HasAttachments,           
+            PageIndex = @PageIndex,   	
+			@TotalRows as TotalRows			       
+			from
+			TopicIds ti
+			inner join [{databaseOwner}].[{objectQualifier}Topic] c	
+			ON c.TopicID = ti.TopicID
+			JOIN [{databaseOwner}].[{objectQualifier}User] b 
+			ON b.UserID=c.UserID
+			join [{databaseOwner}].[{objectQualifier}Forum] d on d.ForumID=c.ForumID
+			WHERE ti.RowNum between @FirstSelectRowNumber and @LastSelectRowNumber
+		order by
+            RowNum ASC 
     
 end
 GO

               (SELECT top 1 LastAccessDate FROM [{databaseOwner}].[{objectQualifier}TopicReadTracking] y WHERE y.TopicID=c.TopicID AND y.UserID = @UserID)
             else ''	 end,
             c.TopicImage,         
             0 as HasAttachments,
            TotalRows = @post_totalrowsnumber,
            PageIndex = @PageIndex,   	
			@TotalRows as TotalRows			       
			from

    @FindLastRead bit = 0
)
AS
begin   
   declare @TotalRows int
   declare @FirstSelectRowNumber int
   declare @LastSelectRowNumber int
   
   -- find total returned count
   select  @TotalRows = COUNT(c.TopicID)
   FROM [{databaseOwner}].[{objectQualifier}Topic] c 
   WHERE c.ForumID = @ForumID
   AND	((c.Priority = 1) OR (c.Priority <=0 AND c.LastPosted>=@Date )) 
