Added return check for pagination