removed some printf and cmd[0] is the total lenght of cmd command array