Bug fixing, ReplaceCommand was improved