Refactor send_command.