improved Factory::createFromString method