Finished basic pagination function besides search