second refactoring, command pattern included