Added function to dynamically invoke a constructor function