Extract Factory class to separate file