Refactor CommandFactory as recommended by Scrutinizer