Tidied up pages.js