next page fix
small JS refactor