Added original code from Command Channel.