Refactering pagination using list.js