Added generic return type to getInstance method, which allows developer
to avoid creating factory methods each time