Added a condition to check for  when assigning cmd to execute.