COMMANDBOX-25 Refactored out command completion UDF to avoid redundancy