Refactor the execution upon receiving a command