handling ValueError in pagenames