Polish pagination logic.