fixed bug that screwed up next page URL and added debug