refactored demos navigation code