diff --git a/frontend/src/Components/MainPage.tsx b/frontend/src/Components/MainPage.tsx
index e04dc918b49fba0e9081f9651f3cdf66299d744d..b30fd8bbeb17373352a4500b09d914b69039946d 100644
--- a/frontend/src/Components/MainPage.tsx
+++ b/frontend/src/Components/MainPage.tsx
@@ -24,7 +24,10 @@ class MainPage extends React.Component<props, state> {
 
   changePage = (increment: boolean) => {
     const newPage = increment ? this.state.currentPage + 1 : this.state.currentPage - 1;
-    this.setState({ currentPage: newPage % this.state.totalPages }); // Go to the new page or loop around if you've hit last page
+      if (newPage == -1)
+          this.setState({ currentPage: this.state.totalPages -1 }); // Negative modulo not supported
+      else
+          this.setState({ currentPage: newPage % this.state.totalPages }); // Go to the new page or loop around if you've hit last page
   };
 
   render() {