updated beforeMove() to include current and next page index