after Zhiheng's refactor,extract a commandfactory