Completed issue #1 / updated pagination function