Added paginate function to help users paginate through database results.