Refactoring for command based interaction