added logic to build arbitrary pages