refactor js to make new page sortable