Adding try and catch for preventing host undefined error and Bad constructor arguments error