Refactoring to passing the type in the Constructor