fixing type factory, was only working for the very first call