To continue building the app I realized that InitMenuBoard.js had to be generalized to a module doing exactly the same work but for many cases. Factory.js is also created as a helper module. InitMenuBoard.js is replaced with InitCollectionView. InitCollectionView throws error if invalid parameters are passed into the module. Hence the module should be called with within a try-catch block.