[#84572026] refactor. extracted private methods
[#84572026] throw an error if command is not found
[#84572026] raise error if command list is empty