Fix up pagenation function
Merge branch 'leon'