Refactored to access database instead of file. Added max number of items per page