fixed paging scheme and solved scoping issues