added subpages, some code refactoring