refactor to command pattern.