diff --git a/src/views/diary.tpl b/src/views/diary.tpl
index b76ca4b..f8ee377 100644
--- a/src/views/diary.tpl
+++ b/src/views/diary.tpl
@@ -29,9 +29,9 @@
% end
% # fill out number cluster to the left when page is high
- % if page >= max_pages - cluster:
- % for j in range(page - cluster):
- {{page + j + cluster + 1}}
+ % if page > max_pages - cluster:
+ % for j in range(cluster - max_pages + page):
+ {{page + j + cluster + 1}}
% end
% end