calculate page count in controller