Upgraded factory to use generics
merge resolved