fixed pagination to only show valid page links