make paginate function use $count variable instead of hard coded #