put null checks in pages.js