paging logic changed. more modularized