shortened pagnation code in search.js