Fixed pagination in which it was not showing the correct number of pages due to use of the incorrect variable.